package com.vivimice.lotroller.device;

import java.util.Map;

import com.vivimice.lotroller.notification.NotificationType;

public abstract class Device {

	private Device nextDevice = null;
	
	public abstract boolean getStatus();
	
	public abstract Map<NotificationType, Object> getDataMap();

	public abstract void close();
	
	protected void triggerNextDevice() {
		if (hasNextDevice()) {
			getNextDevice().trigger();
		}
	}
	
	/**
	 * called when this device is triggered
	 */
	protected void trigger() {
		// default is to trigger next device - chaining
		triggerNextDevice();
	}
	
	protected Device getNextDevice() {
		return nextDevice;
	}
	
	protected boolean hasNextDevice() {
		return nextDevice != null;
	}

	protected void setNextDevice(Device nextDevice) {
		this.nextDevice = nextDevice;
	}

}
